package edu.faytechcc.csc.chat;

import edu.faytechcc.csc.messages.Connection;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * Please describe what this class does here.
 *
 * CSC 251 0001 DATE:
 *
 * @author Stephanie Mckenzie
 */
public class ChatServer
{
    
    public static void main(String[] args)
    {
        ServerSocket serverSocket = null;

        try
        {
            serverSocket = new ServerSocket(4444);
        } catch (IOException e)
        {
            System.out.println("Could not listen on port 4444");
            System.exit(24);
        }

        Socket clientSocket = null;
        try
        {
            System.out.println("Waiting for client connection...");
            clientSocket = serverSocket.accept();
            System.out.println("Client connected: "
                    + clientSocket.getInetAddress());
            System.out.println("+++++++++++++\n");

            Connection conn = new Connection(clientSocket, "Client");
            conn.connect();

            serverSocket.close();
        } catch (IOException e)
        {
            System.out.println("Client Accept failed");
            System.exit(36);
        }
    }
}
